﻿using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace ZenSystemService.Api.Migrations
{
    /// <inheritdoc />
    public partial class TraineeCourseTraining : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.RenameColumn(
                name: "TraineeDeviceId",
                table: "TraineeCourseTrainings",
                newName: "Sequence");

            migrationBuilder.AddColumn<int>(
                name: "ProductId",
                table: "TraineeCourseTrainings",
                type: "int",
                nullable: true);

            migrationBuilder.CreateIndex(
                name: "IX_TraineeCourseTrainings_CourseId",
                table: "TraineeCourseTrainings",
                column: "CourseId");

            migrationBuilder.CreateIndex(
                name: "IX_TraineeCourseTrainings_CourseTrainingItemId",
                table: "TraineeCourseTrainings",
                column: "CourseTrainingItemId");

            migrationBuilder.CreateIndex(
                name: "IX_TraineeCourseTrainings_ProductId",
                table: "TraineeCourseTrainings",
                column: "ProductId");

            migrationBuilder.CreateIndex(
                name: "IX_TraineeCourseTrainings_TraineeId",
                table: "TraineeCourseTrainings",
                column: "TraineeId");

            migrationBuilder.AddForeignKey(
                name: "FK_TraineeCourseTrainings_CourseTrainingItems_CourseTrainingIte~",
                table: "TraineeCourseTrainings",
                column: "CourseTrainingItemId",
                principalTable: "CourseTrainingItems",
                principalColumn: "CourseTrainingItemId",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_TraineeCourseTrainings_Courses_CourseId",
                table: "TraineeCourseTrainings",
                column: "CourseId",
                principalTable: "Courses",
                principalColumn: "CourseId",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_TraineeCourseTrainings_Products_ProductId",
                table: "TraineeCourseTrainings",
                column: "ProductId",
                principalTable: "Products",
                principalColumn: "ProductId");

            migrationBuilder.AddForeignKey(
                name: "FK_TraineeCourseTrainings_Users_TraineeId",
                table: "TraineeCourseTrainings",
                column: "TraineeId",
                principalTable: "Users",
                principalColumn: "UserId",
                onDelete: ReferentialAction.Cascade);
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_TraineeCourseTrainings_CourseTrainingItems_CourseTrainingIte~",
                table: "TraineeCourseTrainings");

            migrationBuilder.DropForeignKey(
                name: "FK_TraineeCourseTrainings_Courses_CourseId",
                table: "TraineeCourseTrainings");

            migrationBuilder.DropForeignKey(
                name: "FK_TraineeCourseTrainings_Products_ProductId",
                table: "TraineeCourseTrainings");

            migrationBuilder.DropForeignKey(
                name: "FK_TraineeCourseTrainings_Users_TraineeId",
                table: "TraineeCourseTrainings");

            migrationBuilder.DropIndex(
                name: "IX_TraineeCourseTrainings_CourseId",
                table: "TraineeCourseTrainings");

            migrationBuilder.DropIndex(
                name: "IX_TraineeCourseTrainings_CourseTrainingItemId",
                table: "TraineeCourseTrainings");

            migrationBuilder.DropIndex(
                name: "IX_TraineeCourseTrainings_ProductId",
                table: "TraineeCourseTrainings");

            migrationBuilder.DropIndex(
                name: "IX_TraineeCourseTrainings_TraineeId",
                table: "TraineeCourseTrainings");

            migrationBuilder.DropColumn(
                name: "ProductId",
                table: "TraineeCourseTrainings");

            migrationBuilder.RenameColumn(
                name: "Sequence",
                table: "TraineeCourseTrainings",
                newName: "TraineeDeviceId");
        }
    }
}
